<template>
	<view class="u-page">
		<!-- <u-list
			 @scrolltolower="scrolltolower" 
		> -->
		<u-list>
			<u-list-item v-for="(item, index) in indexList" :key="index">
				<u-cell :title="`索引-${index}-订单号-${item.scheduleId}-开始时间-${item.startTime}-结束时间-${item.endTime}-设备号-${item.deviceId}-自习室-${item.roomId}`">
					<u-avatar slot="icon" shape="square" size="70" :src="item.url"
						customStyle="margin: -3px 5px -3px 0"></u-avatar>
				</u-cell>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				indexList: [],
				urls: [
					'https://cdn.uviewui.com/uview/album/1.jpg',
					'https://cdn.uviewui.com/uview/album/2.jpg',
					'https://cdn.uviewui.com/uview/album/3.jpg',
					'https://cdn.uviewui.com/uview/album/4.jpg',
					'https://cdn.uviewui.com/uview/album/5.jpg',
					'https://cdn.uviewui.com/uview/album/6.jpg',
					'https://cdn.uviewui.com/uview/album/7.jpg',
					'https://cdn.uviewui.com/uview/album/8.jpg',
					'https://cdn.uviewui.com/uview/album/9.jpg',
					'https://cdn.uviewui.com/uview/album/10.jpg',
				]
			}
		},
		onLoad() {
			uni.request({
				url: 'http://119.23.64.16:8080/schedule/getAllByUserId', //仅为示例，并非真实接口地址。
				//url: 'http://127.0.0.1:8082/schedule/reverse',
				data: {
					userId: '1',
				},
				header: {
					'custom-header': 'hello' //自定义请求头信息
				},
				success: (res) => {
					console.log(res.data);
					this.text = 'request success';
					var that = this;
					if (res.data.status == 200) {
						for (let i = 0; i < res.data.data.length; i++) {
							this.indexList.push({
								url: this.urls[uni.$u.random(0, this.urls.length - 1)],
								scheduleId: res.data.data[i].id,
								startTime: res.data.data[i].startTime,
								endTime: res.data.data[i].endTime,
								deviceId: res.data.data[i].deviceId,
								roomId: res.data.data[i].roomId
							})
						}
					}
				}
			});

		},
		methods: {
			scrolltolower() {

			},
		},
	}
</script>
